1 package org.smartcomps.twister.engine.core.definition;
2
3 import junit.framework.TestCase;
4 import org.smartcomps.twister.engine.priv.core.definition.ProcessFactory;
5 import org.smartcomps.twister.engine.priv.core.definition.impl.ProcessImpl;
6 import org.smartcomps.twister.engine.priv.core.definition.impl.CorrelationSetImpl;
7 import org.smartcomps.twister.common.transaction.TransactionManager;
8 import org.smartcomps.twister.common.lifecycle.LifecycleManager;
9 import org.smartcomps.twister.util.BeanTester;
10 import net.sf.hibernate.tool.hbm2ddl.SchemaExport;
11 import net.sf.hibernate.cfg.Configuration;
12
13 public class TestProcess extends TestCase {
14
15 public static final String CORRELATION_NAME = "order";
16 public static final String CORRELATION_PROP1= "tns:orderid";
17 public static final String CORRELATION_PROP2= "tns:customerid";
18
19 public static ProcessImpl testProcess = null;
20
21 private BeanTester beanTester = new BeanTester(new String[] {"Id"});
22
23 protected void setUp() throws Exception {
24 LifecycleManager.getLifecycleManager().createResources();
25 LifecycleManager.getLifecycleManager().startResources();
26
27 SchemaExport schemaExport = new SchemaExport(new Configuration().configure());
28 schemaExport.create(true, true);
29
30 TransactionManager.beginTransaction();
31 }
32
33 protected void tearDown() throws Exception {
34 TransactionManager.commitTransaction();
35
36 LifecycleManager.getLifecycleManager().stopResources();
37 LifecycleManager.getLifecycleManager().destroyResources();
38 }
39
40 public void testCreate() throws Exception {
41 testProcess = (ProcessImpl) ProcessFactory.createProcess("TestProcess");
42 beanTester.initializeProperties("testProcess", testProcess);
43 TransactionManager.commitTransaction();
44 TransactionManager.beginTransaction();
45
46 ProcessImpl testProcessRes = (ProcessImpl) ProcessFactory.getByName(testProcess.getName());
47 assertTrue("Process attributes values have been changed.", beanTester.testValues("testProcess", testProcessRes));
48 testProcess = testProcessRes;
49 }
50
51 public void testCreateWithCorrelation() throws Exception {
52 testProcess = (ProcessImpl) ProcessFactory.createProcess("TestProcess");
53 beanTester.initializeProperties("testProcess", testProcess);
54 ProcessFactory.addCorrelation(testProcess, CORRELATION_NAME, CORRELATION_PROP1 + " " + CORRELATION_PROP2);
55 ProcessFactory.addProperty(testProcess, CORRELATION_PROP1, "xs:string", "tns:msg1", "main", "/root/orderid");
56 ProcessFactory.addProperty(testProcess, CORRELATION_PROP2, "xs:string", "tns:msg2", "main", "/root/customerid");
57
58 TransactionManager.commitTransaction();
59 TransactionManager.beginTransaction();
60
61 ProcessImpl testProcessRes = (ProcessImpl) ProcessFactory.getByName(testProcess.getName());
62 assertTrue("Process attributes values have been changed.", beanTester.testValues("testProcess", testProcessRes));
63 assertNotNull("Process is not linked with correlation", testProcessRes.getCorrelationSet(CORRELATION_NAME));
64 assertEquals("Correlation properties are wrong", CORRELATION_PROP1 + " " + CORRELATION_PROP2,
65 ((CorrelationSetImpl)testProcessRes.getCorrelationSet(CORRELATION_NAME)).getPropertiesString());
66 testProcess = testProcessRes;
67 }
68 }
This page was automatically generated by Maven